package lab03.test09;

import java.io.*;

public class Test {
    public static void main(String[] args) {
        String path="D:\\book.txt";
        BufferedReader bufferedReader=null;
        BufferedWriter bufferedWriter=null;
        String line=null;
        String[] result=null;
        int value=0;
        try {
            bufferedWriter=new BufferedWriter(new FileWriter("D:\\book.txt"));
            bufferedReader=new BufferedReader(new FileReader(path));
            while ((line=bufferedReader.readLine())!=null) {
                System.out.println(line);
                result=line.split("  ");

                value++;
                if (value==3){
                    result[3]=String.valueOf(Double.parseDouble(result[3])+20);

                }
                if (value==4){
                    result[3]=String.valueOf(Double.parseDouble(result[3])+30);
                }
                String str1=new String(result[0]);
                String str2=new String(result[1]);
                String str3=new String(result[2]);
                String str4=new String(result[3]);
                String str5=new String(result[4]);
                bufferedWriter.write(str1+" "+str2+"  "+str3+"  "+str4+"  "+str5);
                bufferedWriter.newLine();
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                bufferedWriter.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
